module(
    name = "rules_mojo",
    version = "0.6.0",
    bazel_compatibility = [">=8.0.0"],
)

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "rules_python", version = "1.0.0")

mojo = use_extension("//mojo:extensions.bzl", "mojo")
mojo.toolchain()
mojo.gpu_toolchains()
use_repo(mojo, "mojo_gpu_toolchains", "mojo_host_platform", "mojo_toolchains")

register_toolchains("@mojo_toolchains//...", "@mojo_gpu_toolchains//...")

_DEFAULT_PYTHON_VERSION = "3.12"

_PYTHON_VERSIONS = [
    "3.9",
    "3.10",
    "3.11",
    "3.12",
    "3.13",
]

python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True)

[
    python.toolchain(
        ignore_root_user_error = True,
        is_default = version == _DEFAULT_PYTHON_VERSION,
        python_version = version,
    )
    for version in _PYTHON_VERSIONS
]

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip", dev_dependency = True)

[
    pip.parse(
        hub_name = "rules_mojo_test_deps",
        python_version = version,
        requirements_lock = "tests/python/requirements.txt",
    )
    for version in _PYTHON_VERSIONS
]

use_repo(pip, "rules_mojo_test_deps")

versions = use_repo_rule("//tests:versions.bzl", "versions")

versions(
    name = "versions",
    dev_dependency = True,
    python_versions = _PYTHON_VERSIONS,
)

link_hack = use_repo_rule("//mojo/private:link_hack.bzl", "link_hack")

link_hack(
    name = "build_bazel_rules_android",  # See link_hack.bzl for details
)
